package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.user.UserAddress;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.atguigu.spzx.user.service.UserAddressService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName: UserAddressController
 * Package: com.atguigu.spzx.user.controller
 * Description:
 *
 * @Author 刘强
 * @Create 2024/7/17 17:08
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/user/userAddress/auth")
public class UserAddressController {
    @Resource
    private UserAddressService userAddressService;


    /**
     * /api/user/userAddress/auth/getUserAddressById/{id}
     * 根据用户地址id获取用户地址
     * @param id
     * @return
     */
    @GetMapping("getUserAddressById/{id}")
    public UserAddress getUserAddressById(@PathVariable Long id){
        return userAddressService.getUserAddressById(id);
    }


    /**
     *
     * 获取用户的地址列表
     * @return
     */
    @GetMapping("findUserAddressList")
    public Result<List<UserAddress>> findUserAddressList() {
        List<UserAddress> userAddressList = userAddressService.findUserAddressList();
        return Result.build(userAddressList, ResultCodeEnum.SUCCESS);

    }
}
